package business;
import java.util.ArrayList;

import model.PriorityDTO;
import dao.DAOException;
import dao.PriorityDAO;
import dao.DAOFactory;
public class PriorityManager {
	private PriorityDAO priorityDAO;
	
	public PriorityManager() 
	{
		priorityDAO = DAOFactory.loadInstance().getPriorityDAO();
	}
	
	public void insertPriority(PriorityDTO priority)
	{
		try {
			priorityDAO.insertPriority(priority);
		} catch (DAOException e) {
			// TODO: handle exception
			e.printStackTrace();
		}		
	}
	public void deletePriority(PriorityDTO priority) 
	{
		try {
			priorityDAO.deletePriority(priority);
		} catch (DAOException e) {
		// TODO: handle exception
		e.printStackTrace();
	}
		
	}
	
	@SuppressWarnings("finally")
	public ArrayList<PriorityDTO> findAllPriorities()
	{
		ArrayList<PriorityDTO> priorityList = new ArrayList<PriorityDTO>();
		try {
			priorityList =priorityDAO.findAllPriorities();
			
		} catch (DAOException e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		finally{
			return priorityList;
		}
	}
	
	@SuppressWarnings("finally")
	public PriorityDTO findPriority(int priorityID) 
	{
		PriorityDTO currentPririty= new PriorityDTO();
		try
		{
			currentPririty = priorityDAO.findPriority(priorityID);
		}
		catch(DAOException e)
		{
			e.printStackTrace();
		}
		finally
		{
			return currentPririty;
		}
	}	
	
	@SuppressWarnings("finally")
	public ArrayList<PriorityDTO> findAllPriorityName() 
	{
		ArrayList<PriorityDTO> priorityNames= new ArrayList<PriorityDTO>();
		try
		{
			priorityNames = priorityDAO.findAllPriorityNames();
		}
		catch(DAOException e)
		{
			e.printStackTrace();
		}
		finally
		{
			return priorityNames;
		}
	}	
	

}
